<?php

namespace App\Observers;

use App\Models\News;
use Illuminate\Support\Facades\Log;
use Illuminate\Support\Str;

class NewsObserver
{
    public function creating(News $news)
    {
        $news->excerpt = Str::limit($news->body, 100, '...');
    }

    /**
     * Handle the news "created" event.
     *
     * @param \App\Models\News $news
     * @return void
     */
    public function created(News $news)
    {
//        $news->excerpt=Str::limit($news->body,100,'...');
//        $news->save();
    }

    /**
     * Handle the news "updated" event.
     *
     * @param \App\Models\News $news
     * @return void
     */
    public function updated(News $news)
    {
        //
    }

    /**
     * Handle the news "deleted" event.
     *
     * @param \App\Models\News $news
     * @return void
     */
    public function deleted(News $news)
    {
        //
    }

    /**
     * Handle the news "restored" event.
     *
     * @param \App\Models\News $news
     * @return void
     */
    public function restored(News $news)
    {
        //
    }

    /**
     * Handle the news "force deleted" event.
     *
     * @param \App\Models\News $news
     * @return void
     */
    public function forceDeleted(News $news)
    {
        //
    }
}
